#ifndef FOOD_H
#define FOOD_H


class Food
{
    public:
        Food();
        Food(int a_x, int a_y, int _nutritions);
        virtual ~Food();
        Food(const Food& other);
        Food& operator=(const Food& other);
        int GetX() const{return m_x;}
        void SetX(int val) {m_x = val; m_x2=m_x+rectSpace.w;}

        int GetY() const{return m_y; }
        void SetY(int val) {m_y = val; m_y2=m_y+rectSpace.h;}

        int GetNutritions() const{return m_nutritions;}
        void SetNutritions(int val) {m_nutritions = val;}

        int GetX2() const{return m_x2;}
        int GetY2() const{return m_y2;}

        void Draw(SDL_Surface* where);
        void Reduce(){m_nutritions--;}

        SDL_Rect rectSpace;
        SDL_Surface* sprite;

    protected:
    private:
        int m_x;
        int m_y;
        int m_x2;
        int m_y2;
        int m_nutritions;
};

Food::Food()
:m_x(RanGen.IRandom(0,SCREEN_W-100)),m_y(RanGen.IRandom(0,SCREEN_H-100)),m_x2(m_x+100),m_y2(m_y+100),m_nutritions(100)
{
    sprite=food_one;
    rectSpace.x=m_x;
    rectSpace.y=m_y;
    rectSpace.w = 100;
    rectSpace.h = 100;
}

Food::Food(int a_x, int a_y, int a_nutritions)
{
    sprite=food_one;
    rectSpace.x=m_x;
    rectSpace.y=m_y;
    rectSpace.w = 100;
    rectSpace.h = 100;
}

Food::~Food()
{
    //dtor
}


Food::Food(const Food& other)
{
    SetX(other.GetX());
    SetY(other.GetY());
    m_nutritions = other.GetNutritions();
}

Food& Food::operator=(const Food& rhs)
{
    if (this == &rhs) return *this; // handle self assignment
    SetX(rhs.GetX());
    SetY(rhs.GetY());
    m_nutritions = rhs.GetNutritions();
    return *this;
}

void Food::Draw(SDL_Surface* where)
{
    magneta = SDL_MapRGB(sprite->format,255,0,255);
    if(SDL_SetColorKey(sprite,SDL_SRCCOLORKEY | SDL_RLEACCEL,magneta)<0)
    fout<<"Error in setting color key.\n";
    SDL_BlitSurface(sprite, 0, where, &rectSpace);
}
#endif // FOOD_H
